home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Utilities / Programming / Mac F2C 1.2.2 / Mac F2C Documentation / For THINK v6 and Earlier Users / For THINK v6 and Earlier Users. < prev   
Encoding:
Text File  |  1995-01-28  |  12.1 KB  |  320 lines  |  [TEXT/KAHL]

  1.     **************************************
  2.     **************************************
  3.  
  4.         FOR THINK v6 AND EARLIER USERS
  5.  
  6.     **************************************
  7.     **************************************
  8.  
  9. This file provides instructions on how to build the required support 
  10. libraries if you are not using THINK version 7.0 or later.  
  11.  
  12. This file also includes some general guidance for users of other compilers, 
  13. but because I only own THINK C I can only provide general guidance.  
  14. CodeWarrior libraries and example project files are provided courtesy of 
  15. Dirk Froehling, so the only Macintosh compiler for which this remains an 
  16. issue is MPW.
  17.  
  18. Use of Mac F2C code with the C++ compiler is strongly not recommended with 
  19. version 6 of the THINK/Symantec C++ compiler.  There is no C++ compiler 
  20. prior to version 6.  For these reasons, the C++ libraries and C++ model 
  21. projects are omitted from the below discussions.
  22.  
  23. If you have THINK version 6, you can upgrade to version 7 (minus Visual 
  24. Architect and TCL version 2.0) for free.  Look in your favorite Macintosh 
  25. archive site for the free updater.
  26.  
  27.  
  28.  
  29. CONTENTS
  30. ********
  31.  
  32.     A.  BUILDING THE SUPPORT LIBRARIES USING THINK C
  33.     
  34.     B.  CONVERTING THE TEST PROJECT
  35.     
  36.     C.  HOW TO USE THE MODEL PROJECT
  37.     
  38.     D.  IF YOU USE COMPILERS OTHER THAN THINK C
  39.     
  40.     
  41.     
  42. A.  BUILDING THE SUPPORT LIBRARIES USING THINK C
  43. *************************************************
  44.  
  45. There are five support libraries required to run programs translated by 
  46. Mac F2C.  These libraries are:
  47.  
  48.     (1) ANSI F2C
  49.     (2) unix F2C
  50.     (3) libI77a
  51.     (4) libI77b
  52.     (5) libF77
  53.     
  54. You should first install these as specified in the "INSTRUCTIONS (THINK)" 
  55. file.  The first two libraries belong in the "Standard Libraries" folder; 
  56. the second three belong in the "Mac F2C Libraries" folder which you should 
  57. place in the folder that contains the THINK Project Manager (or the THINK C 
  58. application for versions prior to version 6).  
  59.  
  60.  
  61. TO MAKE "ANSI F2C" AND "unix F2C"
  62.  
  63. Delete "ANSI F2C" and "unix F2C" provided with Mac F2C.  Duplicate the 
  64. "ANSI" and "unix" libraries in the "Standard Libraries" folder (the ones 
  65. provided by Symantec).  Rename the duplicates "ANSI F2C" and "unix F2C".  
  66. Open each one and do the following:
  67.  
  68.     (a) Remove objects
  69.     
  70.     (b) In the "Options" dialog select:
  71.         - 4-byte integers
  72.         - 8-byte doubles
  73.         - 68020 code generation (strongly recommended, not required)
  74.  
  75.     (c) In the "Set Project Type" dialog select:
  76.         - Far code
  77.         - Far data
  78.  
  79.     (d) Bring Up To Date
  80.     
  81.  
  82. TO MAKE "libI77a", "libI77b", AND "libF77"
  83.  
  84. In the "Mac F2C Libraries" folder you will find these three libraries and 
  85. two folders of source code ("libI77 Sources" and "libF77 Sources").  In the 
  86. folder "For THINK v6 and Earlier Users" you will find corresponding text 
  87. files called "Contents of xxx".  The files "Contents of xxx" contain 
  88. detailed descriptions of the what each library contains.
  89.  
  90. The process is the same for all three libraries.  I will illustrate it 
  91. with "libI77a":
  92.  
  93.     (a) Delete "libI77a"
  94.     
  95.     (b) Create a new empty project called "libI77a" 
  96.  
  97.     (c) In the "Options" dialog select:
  98.         - 4-byte integers
  99.         - 8-byte doubles
  100.         - 68020 code generation (strongly recommended, not required)
  101.         - remove the prefix "#include <MacHeaders>"
  102.         - add the prefix "#define NON_UNIX_STDIO" (for "libI77a" and "libI77b" only)
  103.         - add the prefix "#define _POSIX_SOURCE"  (for "libI77a" and "libI77b" only)
  104.  
  105.     (d) In the "Set Project Type" dialog select:
  106.         - Far code
  107.         - Far data
  108.         
  109.     (e) Open the text file "Contents of libI77a"
  110.  
  111.     (f) Add source files from the folder "libI77 Sources" as required to match 
  112.         the list that appears in "Contents of libI77a"
  113.         
  114.     (g) Bring the project up to date
  115.     
  116. Repeat this process with "libI77b" and "libF77".  "libF77" contains over 
  117. one hundred files.  You may find it easier to include all the source files 
  118. in the folder "libF77 Sources" initially and then remove the handful that 
  119. don't belong in "libF77".
  120.  
  121.  
  122.  
  123. B.  CONVERTING THE TEST PROJECT
  124. *******************************
  125.  
  126. The folder "Test Project ƒ" contains a project file called "Test.π".  In 
  127. the folder "For THINK v6 and Earlier Users" is a text file called "Contents 
  128. of Test.π".  This file describes in detail the contents of the test 
  129. project.  To create a version compatible with your version of THINK C, do 
  130. the following:
  131.  
  132.     (a) Delete "Test.π"
  133.     
  134.     (b) Create a new empty project called "Test.π"
  135.  
  136.     (c) In the "Options" dialog select:
  137.         - 4-byte integers
  138.         - 8-byte doubles
  139.         - 68020 code generation (strongly recommended, not required)
  140.         - remove the prefix "#include <MacHeaders>"
  141.  
  142.     (d) In the "Set Project Type" dialog select:
  143.         - Far code
  144.         - Far data
  145.         
  146.     (e) Open the text file "Contents of Test.π"
  147.  
  148.     (f) Add sources and libraries as required to match the list that appears 
  149.         in "Contents of Test.π" (You will not be able to add "Test.c" 
  150.         until you create it by translating "Test.f" with Mac F2C)
  151.         
  152.     (f) Segment the project as indicated in "Contents of Test.π" (in some 
  153.         versions of THINK C you cannot name the segments; this is not a 
  154.         problem, just ignore the segment names).
  155.  
  156.  
  157.  
  158. C.  HOW TO USE THE MODEL PROJECT
  159. ********************************
  160.  
  161. The project model is the folder "Mac F2C Project" which is located in the 
  162. folder "For '(Project Models)'".  The folder "Mac F2C Project" contains 
  163. the following files:
  164.  
  165.     (1) "@1.π" -- a THINK C version 7.0 project file.
  166.     
  167.     (2) "main.c" -- a driver program required to run programs compiled by 
  168.                     Mac F2C.
  169.                     
  170.     (3) "f2c.h" -- a header file required by code compiled by Mac F2C.
  171.     
  172. This what you need to compile, link, and run files produced by Mac F2C.  
  173. In THINK C version 7.0 or later, the THINK project manager automatically 
  174. makes a copy of the entire model project (i.e., the entire "Mac F2C 
  175. Project" folder) and renames the folder and project file when you create 
  176. a new project using this model.  To use the project model with versions 
  177. of THINK C prior to 7.0, you will need to:
  178.     
  179.     (a) replace "@1.π" which a project compatible with your version of 
  180.         THINK C
  181.     
  182.     (b) every time you want to create a new project for Mac F2C code, 
  183.         duplicate the project model folder by hand and rename the folder 
  184.         and project file by hand.
  185.         
  186. In the folder "For THINK v6 and Earlier Users" is a text file called 
  187. "Contents of @1.π".  This file describes in detail the contents of the 
  188. model project.  To create a version of "@1.π" compatible with your version 
  189. of THINK C, do the following:
  190.  
  191.     (a) Delete "@1.π"
  192.     
  193.     (b) Create a new empty project called "@1.π"
  194.  
  195.     (c) In the "Options" dialog select:
  196.         - 4-byte integers
  197.         - 8-byte doubles
  198.         - 68020 code generation (strongly recommended, not required)
  199.         - remove the prefix "#include <MacHeaders>"
  200.  
  201.     (d) In the "Set Project Type" dialog select:
  202.         - Far code
  203.         - Far data
  204.         
  205.     (e) Open the text file "Contents of @1.π"
  206.  
  207.     (f) Add sources and libraries as required to match the list that appears 
  208.         in "Contents of @1.π"
  209.         
  210.     (g) Segment the project as indicated in "Contents of @1.π" (in some 
  211.         versions of THINK C you cannot name the segments; this is not a problem).
  212.  
  213.  
  214.  
  215. D.  IF YOU USE COMPILERS OTHER THAN THINK C
  216. *******************************************
  217.  
  218. If you use a compiler other than THINK C, you will have to make libraries 
  219. on your own and you will almost certainly have to make some minor 
  220. modifications to some of the source files in the support libraries.
  221.  
  222. You can use the "Contents of xxx" files in the "For THINK v6 and Earlier 
  223. Users" folder to figure out what to put in each library.  If your 
  224. compiler/linker allows libraries larger than 32K, you can combine "libI77a" 
  225. and "libI77b" into a single library.  You could also combine all three 
  226. ("libI77a", "libI77b", and "libF77") into a single library if you so 
  227. desire.
  228.  
  229. Make sure to compile the libraries so that integers are 4-bytes, doubles 
  230. are 8-bytes, and you can have more than 32K of static/global data and jump 
  231. tables larger than 32K.  See the section on Using Code Produced by Mac F2C 
  232. in the "INTRUCTIONS (THINK)" or "INSTRUCTIONS (CodeWarrior)" file for more 
  233. information on these requirements and when they can be relaxed.
  234.  
  235. You must also #define the following things when compiling these files:
  236.  
  237. For "libF77"
  238.     
  239.     <None>
  240.     
  241. For "libI77a" and "libI77b" 
  242.  
  243.     #define NON_UNIX_STDIO          -- force the use of ANSI standard I/O
  244.     #define _POSIX_SOURCE        -- force the use of mktemp() functions
  245.  
  246. Most of the files in the Mac F2C support libraries compile without 
  247. trouble on Macintoshes.  Nevertheless, I had to modify a few files, 
  248. and in doing so I sometimes had to rely on features specific to THINK 
  249. C.  The files in question are:
  250.  
  251. In "libI77"
  252.  
  253.     access.c        This function returns 0 if file called fileName 
  254.                          exists, 1 otherwise.  I wrote this from 
  255.                          scratch using a Macintosh Toolbox call, so 
  256.                          it should work with any Macintosh compiler.
  257.     
  258. In "libF77"
  259.  
  260.     erf_fctns.c    THINK C does not provide error functions in their 
  261.                          library.  I wrote my own.  They have decent numeric 
  262.                          properties and will compile with any ANSI C compiler.   
  263.                          You may wish to replace it with (perhaps faster) 
  264.                          vendor provided error functions.
  265.     
  266.     getenv_.c      I had to write my own.  I wrote one that returns a 
  267.                          blank environment string.  Modify as appropriate for 
  268.                          your compiler.
  269.  
  270.     getpid.c        I had to write my own.  I exploited a global variable 
  271.                         that is defined and maintained by the THINK C unix 
  272.                         library.  CodeWarrior doesn't define these, so we 
  273.                         defined our own. You will have to modify this file 
  274.                         to work with your system.  If all else fails, 
  275.                         return 0.
  276.  
  277.  
  278. Code produced by Mac F2C also relies on the THINK C ANSI and unix 
  279. libraries.  The THINK C ANSI library is exactly what it says it is.  Your 
  280. compiler should include such a library.  The THINK C unix library provides 
  281. a large collection of functions commonly available on unix systems.  Your 
  282. compiler may or may not include such a library.  If it doesn't, you will 
  283. get link errors when compiling programs produced by Mac F2C.  You will have 
  284. to provide the missing functions yourself.  It's actually not hard to do, 
  285. especially because in many cases you only need a place holder function 
  286. (e.g., see "getenv_.c" or "getpid.c").  When a placeholder isn't enough, 
  287. you can figure what the function needs to do by checking a unix manual or 
  288. using the "man" command on a unix system.
  289.  
  290. In any case make sure your versions of the ANSI and unix libraries are 
  291. compiled with the proper options (4-byte integers, 8-byte doubles, jump 
  292. tables larger than 32K, global data larger than 32K, and any C++ 
  293. compatibility options if you plan to ever produce C++ code as Mac F2C 
  294. output).
  295.  
  296. Finally, to run a program translated by Mac F2C, you need to link the 
  297. following things together (this is automatically set up for THINK C users 
  298. by the model project:
  299.  
  300.     -   your translated code
  301.     -   "main.c"
  302.     -   libI77a
  303.     -   libI77b
  304.     -   libF77
  305.     -   ANSI
  306.     -   unix
  307.     
  308. The file "main.c" is a driver that sets up a bunch of things and then calls 
  309. the translated version of the FORTRAN main program.  I modified "main.c" to 
  310. use the THINK C console interface.  In particular, "main.c" calls the 
  311. function ccommand() to get command-line arguments from the user.  You will 
  312. need to modify this accordingly for your compiler.
  313.  
  314. Good luck.  If you have any questions, feel free to email me at 
  315. igormt@alumni.caltech.edu.  If you make a stable, general purpose port of 
  316. the libraries and/or "main.c" to another Macintosh compiler, send me a copy 
  317. and I will include it in future distributions of Mac F2C (with full credit 
  318. and much gratitude).
  319.                     
  320.